<template>
	<view>
		<view class="p-4 flex flex-column grid-gap-4">
			<view class="bg-white rounded-4">
				<input type="text" class="p-4" placeholder="新密码" v-model="form.password">
			</view>
			<view class="bg-white rounded-4">
				<input type="text" class="p-4" placeholder="确认密码" v-model="form.vpassword">
			</view>

			<view class="flex">
				<button class="flex-1 btn-primary btn-round" @tap="submit()">提交</button>
			</view>
		</view>
	</view>
</template>

<script setup lang="ts">
import { ref, nextTick } from 'vue';
import { onLoad, onUnload } from '@dcloudio/uni-app';
import { useWebConfigStore, useUserStore, useRefs } from "@/stores";
import { $page, $api, $http, $message } from "@/utils";
const WebConfigStore = useWebConfigStore();
const { WEBCONFIG } = useRefs(WebConfigStore);
const UserStore = useUserStore();
const { USERINFO } = useRefs(UserStore);
const form = ref({
	password: '',
	vpassword: '',
});
const submit = () => {
	uni.showLoading({ title: '保存中...' });
	$api.User.password(form.value).then(res => {
		uni.hideLoading();
		$message.success(res.msg);
		nextTick(() => {
			$page.back();
		}, 1000);
	}).catch(err => {
		uni.hideLoading();
		$message.error(err.msg);
	})
}
</script>

<style lang="scss" scoped></style>
